public class Test14_threadgroup {
    public static void main(String[] args) {
        TestThread task1=new TestThread();
        TestThread task2=new TestThread();
        ThreadGroup threadGroup=new ThreadGroup("新建的线程");
        //创建两个线程，与两个任务绑定
        Thread t0=new Thread(threadGroup,task1);
        Thread t1=new Thread(threadGroup,task2);
        t0.start();
        t1.start();
        //**线程组中断，则这个组中的所有的线程全部中断。
        threadGroup.interrupt();

    }
}
class TestThread implements Runnable{

    @Override
    public void run() {
        try {
           while(!Thread.currentThread().isInterrupted()){
               System.out.println("线程名："+Thread.currentThread().getName());
               Thread.sleep(3000);
           }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
